import Vue from 'vue'
import App from './App.vue'
import router from './router'
import filter from "@/filter/filter"
import httpRequest from '@/utils/httpRequest'
import ElementUI from 'element-ui'
import 'element-ui/lib/theme-chalk/index.css'

Vue.config.productionTip = false;

Vue.use(ElementUI)

/**全局过滤器*/
Object.keys(filter).forEach(key => {
  Vue.filter(key,filter[key])
});

/**路由登陆拦截*/
router.beforeEach((to,from,next) =>{
  //要不要对meta.LoginRequire属性做监控拦截
  if(to.matched.some(function (item){
    return item.meta.loginRequire;
  })){
    let loginUser = Tool.getLoginUser();
    if(Tool.isEmpty(loginUser)){
      next('/login');
    }else {
      next();
    }
  }else{
    next();
  }
});

// 挂载全局
Vue.prototype.$http = httpRequest // ajax请求方法

new Vue({
  router,
  render: h => h(App),
}).$mount('#app');

console.log("环境：",process.env.NODE_ENV);